<?php
class PhicdcbsController extends AppController {

	var $name = 'Phicdcbs';

	function index() {
		$this->Phicdcb->recursive = 0;
		$this->set('phicdcbs', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid phicdcb', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('phicdcb', $this->Phicdcb->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Phicdcb->create();
			if ($this->Phicdcb->save($this->data)) {
				$this->Session->setFlash(__('The phicdcb has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The phicdcb could not be saved. Please, try again.', true));
			}
		}
		$chidoancbs = $this->Phicdcb->Chidoancb->find('list');
		$loaichiphis = $this->Phicdcb->Loaichiphi->find('list');
		$this->set(compact('chidoancbs', 'loaichiphis'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid phicdcb', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Phicdcb->save($this->data)) {
				$this->Session->setFlash(__('The phicdcb has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The phicdcb could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Phicdcb->read(null, $id);
		}
		$chidoancbs = $this->Phicdcb->Chidoancb->find('list');
		$loaichiphis = $this->Phicdcb->Loaichiphi->find('list');
		$this->set(compact('chidoancbs', 'loaichiphis'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for phicdcb', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Phicdcb->delete($id)) {
			$this->Session->setFlash(__('Phicdcb deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Phicdcb was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
?>